﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Assignment5;
using System;
using System.Collections.Generic;
using System.Text;

namespace Assignment5.TestModify
{
    [TestClass()]
    public class OrderServiceTestModify
    {
        [TestMethod()]
        public void modifyOrderTest()
        {
            Dictionary<Goods, int> oC = new Dictionary<Goods, int>();
            Goods A = new Goods("A", 200);
            Goods B = new Goods("B", 100);
            Goods C = new Goods("C", 50);
            oC.Add(A, 10);
            oC.Add(B, 20);
            Dictionary<Goods, int> oC1 = new Dictionary<Goods, int>();
            oC1.Add(A, 10);
            oC1.Add(C, 40);
            Customer c = new Customer("Bob", true);
            Customer c1 = new Customer("Alice", true);
            Customer c2 = new Customer("Cary", false);
            Time time = new Time(2023, 3, 22, 19, 53);
            Time time1 = new Time(2022, 2, 5, 6, 23);
            OrderService orderService1 = new OrderService();
            orderService1.AddOrder(c1, oC, time);
            orderService1.AddOrder(c, oC1, time);
            orderService1.modifyOrder(orderService1.Search(c1)[0].ID, c2);
            orderService1.modifyOrder(orderService1.Search(c)[0].ID, time1);
            orderService1.modifyOrder(orderService1.Search(c)[0].ID, oC);
            Assert.AreEqual(1, orderService1.Search(c2).Count);
            Assert.AreEqual(2, orderService1.Search(oC).Count);
        }
    }
}